//
//  SystemNotificationListViewController.m
//  MemberProject
//
//  Created by macbook on 15/4/15.
//  Copyright (c) 2015年 MAC OS X. All rights reserved.
//

#import "SystemNotificationListViewController.h"
#import "SystemNoticeModel.h"
@interface SystemNotificationListViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(strong,nonatomic)NSArray *data;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@end

@implementation SystemNotificationListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"系统通知";
    
    self.tableView.dataSource=self;
    self.tableView.delegate=self;
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"CellIdentifier"];
    
    ModelUser *modeluser = [UserInfoManager sharedManager].modelMser;
    
    NSDictionary *parameters1 = @{@"token":@"sdfsadfsadfasdf",@"module":@"_VolunteerNotice",@"method":@"getVNoticesByGroupId",@"requestId":[NSNull new],@"requestParam":@[modeluser.groupCode]};
    
    [SVProgressHUD show];
    //responseData
    [Utils requestDic:parameters1 andRusult:^(id result) {
        [SVProgressHUD dismiss];
        NSArray *resultArr=result;
        if(resultArr.count!=0){
            NSMutableArray *arrM=[NSMutableArray array];
            for(int i=0;i<resultArr.count;i++){
                SystemNoticeModel *model=[SystemNoticeModel getClassForDic:resultArr[i]];
                [arrM addObject:model];
            }
            self.data=arrM;
            [self.tableView reloadData];
        
        }
    } andError:^(id result) {
        [SVProgressHUD showErrorWithStatus:@"网络错误"];
    }];
}

#pragma mark - tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.data.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier=@"CellIdentifier";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    SystemNoticeModel *model=self.data[indexPath.row];
    cell.textLabel.text=model.noticeTitle;
    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end
